{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tkinter as tk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "window = tk.Tk()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "window.title(\"my window\")\n",
    "window.geometry(\"200x100\") # 长x宽\n",
    "\n",
    "var = tk.StringVar(window)\n",
    "\n",
    "l = tk.Label(window, textvariable=var, \n",
    "             bg=\"green\", \n",
    "             font=(\"Arial\", 12), \n",
    "             width = 15, \n",
    "             height = 2)\n",
    "l.pack()\n",
    "# l.place()\n",
    "\n",
    "on_hit = False\n",
    "def hit_me():\n",
    "    global on_hit\n",
    "    if on_hit == False:\n",
    "        var.set(\"you hit me\")\n",
    "    else:\n",
    "        var.set(\"\")\n",
    "    on_hit = not on_hit\n",
    "\n",
    "b = tk.Button(window, text=\"hit me\", \n",
    "             width=15, height=2, \n",
    "             command=hit_me)\n",
    "b.pack()\n",
    "\n",
    "window.mainloop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
